package com.roomwrod.livedata.repository;

import android.content.Context;

import com.roomwrod.App;
import com.roomwrod.db.WordDao;
import com.roomwrod.model.Word;

import java.security.Key;
import java.util.List;

import androidx.arch.core.executor.ArchTaskExecutor;
import androidx.lifecycle.LiveData;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

public class WordRepository {

    WordDao dao;
    public LiveData<List<Word>> getAll;

    public WordRepository() {
        dao = App.APP_DATA_BASE.getWordDao();
        getAll = dao.getAllData();
    }

    public LiveData<List<Word>> getfindKeys(String key) {
        return dao.findKeysData("%" + key + "%");
    }

    public void insert(Word... words) {
        dao.insert(words);
    }

    public void delete(int id) {
        dao.delete(id);
    }

    public void update(Word... words) {
        dao.update(words);
    }

    public void clear() {
        dao.clear();
    }
}
